home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: dmocc2.on.bell.ca!bc2cep!news
- From: Eric Marc Loebenberg <loebenbe@qc.bell.ca>
- Subject: Can you help? Switching menus stored in DLL Resource
- X-Nntp-Posting-Host: cmocft.qc.bell.ca
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <316EC457.1AAE@qc.bell.ca>
- Sender: news@on.bell.ca (news admin)
- Content-Transfer-Encoding: 7bit
- Organization: Bell Sygma
- Mime-Version: 1.0
- Date: Fri, 12 Apr 1996 21:00:07 GMT
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- Hi perhaps someone can give me a hand.
- I am using Visual C++ versions 4.0 and 1.52 (separately)
-
- I am building an application that will run in 1 of several languages.
- All linguistic resources are stored in a DLL for that language.
-
- I thought it would be need to be able to switch the language on the fly
- while running the application. For example, to to the Options menu
- Language submenu and pick a language.
-
- I would then drop one DLL load the other, kill the menu and load the
- new menu.
-
- THIS ALMOST WORKS with one problem.
- All strings and dialogs appear in the new language and so does the
- menu. HOWEVER, when I choose a submenu, I get
-
- In Version 1.52 Debug
- Assertion Failed: file Winmenu.cpp Line 42
-
- This line is flagged with a * below
-
- CMenu* PASCAL CMenu::FromHandle(HMENU hMenu)
- {
- CMenu* pMenu = (CMenu*)_afxMapHMENU.FromHandle(hMenu);
- * ASSERT(pMenu == NULL || pMenu->m_hMenu == hMenu);
- return pMenu;
- }
-
- The code that I am using to switch languages is
-
- void CMptFrame::SetLanguage(char cLang)
- {
- CMenu *ThisMenu = GetMenu();
- ThisMenu->DestroyMenu();
- ThisDoc->Lang = cLang;
- ThisApp.DLL[ThisApp.DLLLangIndex] = cLang;
- FreeLibrary(ThisApp.m_hInstDLL);
- ThisApp.m_hInstDLL =::LoadLibrary(ThisApp.DLL);
- AfxSetResourceHandle(ThisApp.m_hInstDLL); // get resources from DLL
- ThisMenu->LoadMenu(IDR_MAINFRAME);
- SetMenu(ThisMenu);
- DrawMenuBar();
- }
-
- Thanks.
-